package org.hermes.core;

import java.util.ArrayList;
import java.util.Collection;

import org.hermes.core.message.ServiceMessage;

public class ServiceResponse {
	public static final int STATUS_OK = 1;
	public static final int STATUS_EXCEPTION = 2;
	
	private int status;
	private Object responseData;
	private Collection<ServiceMessage> serviceMessages;

	public ServiceResponse(){
	}
	
	public ServiceResponse(int status, String msg){
		this.status = status;
		serviceMessages = new ArrayList<ServiceMessage>();
		serviceMessages.add(new ServiceMessage(msg, ServiceMessage.TYPE_ERROR));
	}
	
	public ServiceResponse(int status, Object responseData, Collection<ServiceMessage> serviceMsg) {
		this.status = status;
		this.responseData = responseData;
		this.serviceMessages = serviceMsg;
	}

	public int getStatus() {
		return status;
	}

	public Object getResponseData() {
		return responseData;
	}

	public Collection<ServiceMessage> getServiceMessages() {
		return serviceMessages;
	}

	public void setStatus(int status) {
		this.status = status;
	}

	public void setResponseData(Object responseData) {
		this.responseData = responseData;
	}

	public void setServiceMessages(Collection<ServiceMessage> serviceMessages) {
		this.serviceMessages = serviceMessages;
	}
	
	public void addServiceMessage(ServiceMessage serviceMsg){
		if(serviceMessages == null){
			serviceMessages = new ArrayList<ServiceMessage>();
		}
		
		serviceMessages.add(serviceMsg);
	}
}
